package org.vacoor.nothing.misc.express.usps.api.address;

import org.vacoor.nothing.misc.express.usps.api.UspsRequest;
import org.vacoor.nothing.misc.express.usps.api.data.UspsAddress;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 地址标准化
 * <p/>
 * Address Standardization Web Tool
 * https://www.usps.com/business/web-tools-apis/address-information-api.htm#_Toc365012999
 * 请求: <br />
 * API: Verify
 * XML:
 * <pre>
 * <AddressValidateRequest USERID="xxxxxxx">
 *     <Address ID="0">
 *         <Address1></Address1>
 *         <Address2>6406 Ivy Lane</Address2>
 *         <City>Greenbelt</City>
 *         <State>MD</State>
 *         <Zip5></Zip5>
 *         <Zip4></Zip4>
 *     </Address>
 * </AddressValidateRequest>
 * </pre>
 * 响应:
 * <pre>
 * <AddressValidateResponse>
 *      <Address ID="0">
 *          <Address2>6406 IVY LN</Address2>
 *          <City>GREENBELT</City>
 *          <State>MD</State>
 *          <Zip5>20770</Zip5>
 *          <Zip4>1441</Zip4>
 *      </Address>
 * </AddressValidateResponse>
 * </pre>
 *
 * @author vacoor
 */
@XmlRootElement(name = "AddressValidateRequest")
public class ASRequest extends UspsRequest {
    public static final String API = "Verify";

    @XmlElement(name = "Address")
    private List<UspsAddress> addresses;

    public ASRequest() {
        super(NO_REVISION);
        this.addresses = new ArrayList<UspsAddress>();
    }

    public ASRequest add(UspsAddress... addresses) {
        Collections.addAll(this.addresses, addresses);
        return this;
    }
}
